from django.db import models

# Create your models here.
class UserInfo(models.Model):
#自动创建id，自增主键
    username = models.CharField(max_length=32,blank=True)
    password = models.CharField(max_length=64,null=True,help_text='pwd')
    email = models.EmailField(max_length=60,null=True)
    user_type_choices = (
            (1,'超级用户'),
            (2, '超超级用户'),
            (3, '普通用户'),
        )
    user_type_id = models.IntegerField(choices=user_type_choices,default=1)
    user_group = models.ForeignKey('Usergroup',on_delete=models.SET,to_field='uid',default=1) #建立外键关系

#数据存储在内存，避免连表查询

class Usergroup(models.Model):
    uid = models.AutoField(primary_key=True) #自增主键
    caption = models.CharField(max_length=32)
    ctime = models.DateTimeField(auto_now_add=True,null=True)
    uptime = models.DateTimeField(auto_now=True, null=True)

